import { GBox } from "../../../../../com/mui/containers/GBox";
import { GBoxDirection } from "../../../../../com/mui/containers/globalVariable/GBoxDirection";
import { SPublicMiniPlayer } from "../../../../../Message/Public/SPublicMiniPlayer";
import { LoveTaskInviteItem } from "./LoveTaskInviteItem";
import { ObjectPool } from "../../../../../com/gengine/utils/pools/ObjectPool";
//class LoveTaskInviteList
    
    export  class LoveTaskInviteList /* flash.display.Sprite */
    {
        constructor()
        {
            
            this.initUI();
            return;
        }

        /* internal  */initUI(): void
        {
            this._bodyBox = new GBox();
            this._bodyBox.direction = GBoxDirection.VERTICAL;
            addChild(this._bodyBox);
            return;
        }

        /* internal  */getItemByPlayer(arg1: SPublicMiniPlayer): LoveTaskInviteItem
        {
            var loc1=0;
            var loc3=null;
            var loc2=this._bodyBox.numChildren;
            while (loc1 < loc2) 
            {
                if ((loc3 = this._bodyBox.getChildAt(loc1) as LoveTaskInviteItem).info == arg1) 
                {
                    return loc3;
                }
                ++loc1;
            }
            return null;
        }

        public addItem(arg1: SPublicMiniPlayer): void
        {
            var loc1=ObjectPool.getObject(LoveTaskInviteItem);
            loc1.updateData(arg1);
            this._bodyBox.addChild(loc1);
            return;
        }

        public delItem(arg1: SPublicMiniPlayer): void
        {
            var loc1=this.getItemByPlayer(arg1);
            if (loc1) 
            {
                this._bodyBox.removeChild(loc1);
                this._bodyBox.layChildChanged = true;
            }
            return;
        }

        public invalidateList(): void
        {
            this._bodyBox.invalidate();
            this._bodyBox.y = (155 - this.height) / 2;
            if (this._bodyBox.y < 0) 
            {
                this._bodyBox.y = 0;
            }
            return;
        }

        public dispose(): void
        {
            var loc1=null;
            while (this._bodyBox.numChildren > 0) 
            {
                loc1 = this._bodyBox.getChildAt(0) as LoveTaskInviteItem;
                loc1.dispose();
                this._bodyBox.removeChild(loc1);
                ObjectPool.disposeObject(loc1, LoveTaskInviteItem);
            }
            return;
        }

        public /* override */ get height(): number
        {
            return this._bodyBox.numChildren * 40;
        }

        /* internal */ /* var */_bodyBox: GBox;
    }
